<extend name="Public/common" />
<block name="body">
<div class="page">
  <div class="fixed-bar">
	<include file="Public:usermenu" />
  </div>
  <div class="fixed-empty"></div>
  <form id="form1" method="post" name="form1">
    <input type="hidden" name="group_id" value="{$info['group_id']}" />
    <input type="hidden" name="store_id" value="{$info['store_id']}" />
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="group_name">权限组名称:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="{$info['group_name']}" name="group_name" id="group_name" class="txt"></td>
          <td class="vatop tips"></td>
        </tr>
         <tr>
          <td colspan="2" class="required"><label for="group_desc">权限组描述:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><textarea name="group_desc" rows="6" class="tarea" id="group_desc">{$info['group_desc']}</textarea></td>
          <td class="vatop tips"><span class="vatop rowform">权限组简单的说明，防止备忘</span></td>
        </tr> 
        <tr>
          <td colspan="2" class="required">
          <label><input id="moduleAll" value="1" type="checkbox">&nbsp;&nbsp;全选</label>
		  </td>
        </tr>
        <tr>
          <td colspan="2"><table class="table tb-type2 nomargin module_all">
          <volist name="modules" id="mo">
          <php> if (! in_array($mo['module_id'], $store_auth)){  </php>
              <thead>
                <tr class="space">
                  <th><label><input class="module" name="rules[]" value="{$mo['module_id']}" type="checkbox"  <if condition="in_array($mo['module_id'], $rules)">checked="checked"</if> >&nbsp;&nbsp;{$mo['module_title']}</label></th>
                </tr>
              </thead>
              <tbody>
                <volist name="mo.children" id="vo">
                <tr>
                  <td>
                  <label style="width:100px">&nbsp;</label>
                  <label><input type="checkbox" class="module_row" name="rules[]" value="{$vo['module_id']}"  <if condition="in_array($vo['module_id'], $rules)">checked="checked"</if> >
                    <b>{$vo['module_title']}</b>&nbsp;&nbsp;</label>
                      <volist name="vo.children" id="voo">
                        <label><input type="checkbox" name="rules[]" value="{$voo['module_id']}" <if condition="in_array($voo['module_id'], $rules)">checked="checked"</if> >
                        {$voo['module_title']}&nbsp;</label>
                      </volist>
                    </td>
                </tr>
                </volist>
              </tbody>
          <php>}</php>
          </volist>    
            </table></td>
        </tr>   
      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="15" ><a href="JavaScript:void(0);" class="btn" id="submit"><span>提交</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script>

$(function(){
	
	$('#moduleAll').click(function(){
		$('input[type="checkbox"]').attr('checked',$(this).attr('checked') == 'checked');
	});
	
    $('.module').on('change',function(){
        $(this).parent().parent().parent().parent().next().find('input').prop('checked',this.checked);
    });
    $('.module_row').on('change',function(){
        $(this).parent().parent().find('input').prop('checked',this.checked);
    });

	
	$("#submit").click(function(){
	    if($("#form1").valid()){
	     $("#form1").submit();
		}
	});


	$("#form1").validate({
		errorPlacement: function(error, element){
			error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        rules : {
            group_name : {
                required : true
            }
        },
        messages : {
        	group_name : {
                required : '权限组名称必须填写'
            }
        }
	});	
})
</script>
</block>